package controller.admin.employee;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import model.DTO.EmployeeCreateDTO;
import service.Impl.EmployeeServiceImpl;
import util.GetJsonUtil;
import util.ResultUtil;

import java.io.IOException;
@WebServlet("/admin/employee")
public class EmployeeCreateController extends HttpServlet {
    //新增员工
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        EmployeeCreateDTO e= (EmployeeCreateDTO) GetJsonUtil.get(req,new EmployeeCreateDTO());
        EmployeeServiceImpl service=new EmployeeServiceImpl();
        service.Create(e.getIdNumber(),e.getName(),e.getPhone(),e.getGender(),e.getUsername());

        String json= ResultUtil.getJSON(null,"ok");
        resp.getWriter().write(json);
    }
}
